<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取可视窗口的大小</title>
</head>
<body>

</body>
<script>
    function getViewportOffset() {
        if (window.innerWidth) {
            return {
                w : window.innerWidth,
                h : window.innerHeight
            }
        }else{
            if (document.compatMode == "BackCompat") {
                return {
                    w : document.body.clientWidth,
                    h : document.body.clientHeight
                }
            }else{
                return {
                    w : document.documentElement.clientWidth,
                    h : document.documentElement.clientHeight
                }
            }
        }
    }
</script>
</html>
